import 'package:custom_switch/custom_switch.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:qclock/global.dart';
import 'package:qclock/main_manager.dart';

class Setting extends StatefulWidget {
  Setting({Key key}) : super(key: key);
  @override
  _SettingState createState() => _SettingState();
}

class _SettingState extends State<Setting> {
  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    MainManager _mainManager = Provider.of<MainManager>(context);

    return Scaffold(
      body: Container(
        height: MediaQuery.of(context).size.height,
        child: Column(
          mainAxisAlignment: MainAxisAlignment.spaceAround,
          children: <Widget>[
            Row(
              mainAxisAlignment: MainAxisAlignment.center,
              crossAxisAlignment: CrossAxisAlignment.center,
              children: [
                Text(
                  '日间主题：',
                  style: TextStyle(
                    color: Global.fontColor,
                    fontSize: 20,
                    fontWeight: FontWeight.w600,
                  ),
                ),
                CustomSwitch(
                  activeColor: _mainManager.primaryColor,
                  value: _mainManager.themeLightStatus,
                  onChanged: (value) {
                    setState(
                        () => {_mainManager.changeThemeLightStatus(value)});
                  },
                ),
              ],
            ),
            Row(
              mainAxisAlignment: MainAxisAlignment.center,
              crossAxisAlignment: CrossAxisAlignment.center,
              children: [
                Text(
                  '显示时分：',
                  style: TextStyle(
                    color: Global.fontColor,
                    fontSize: 20,
                    fontWeight: FontWeight.w600,
                  ),
                ),
                CustomSwitch(
                  activeColor: _mainManager.primaryColor,
                  value: _mainManager.showTimeStatus,
                  onChanged: (value) {
                    setState(() => {_mainManager.changeShowTimeStatus(value)});
                  },
                ),
              ],
            ),
            Row(
              mainAxisAlignment: MainAxisAlignment.center,
              crossAxisAlignment: CrossAxisAlignment.center,
              children: [
                Text(
                  '显示秒数：',
                  style: TextStyle(
                    color: Global.fontColor,
                    fontSize: 20,
                    fontWeight: FontWeight.w600,
                  ),
                ),
                CustomSwitch(
                  activeColor: _mainManager.primaryColor,
                  value: _mainManager.showSecondStatus,
                  onChanged: (value) {
                    setState(
                        () => {_mainManager.changeShowSecondStatus(value)});
                  },
                ),
              ],
            ),
            Row(
              mainAxisAlignment: MainAxisAlignment.center,
              crossAxisAlignment: CrossAxisAlignment.center,
              children: [
                Text(
                  '24H格式：',
                  style: TextStyle(
                    color: Global.fontColor,
                    fontSize: 20,
                    fontWeight: FontWeight.w600,
                  ),
                ),
                CustomSwitch(
                  activeColor: _mainManager.primaryColor,
                  value: _mainManager.h24,
                  onChanged: (value) {
                    setState(() => {_mainManager.changeH24(value)});
                  },
                ),
              ],
            ),
          ],
        ),
      ),
    );
  }
}
